Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send more keys with VimuxSendKeys #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slowkow
Copy link

@slowkow slowkow commented May 23, 2014

This patch addresses issue #44, where @gberenfield says:

I can't seem to paste in around 30-40 lines of code into my vimux repl.
Anything less works fine.

I write the selected text to a temporary file, read the file with tmux,
and paste the contents into the appropriate window.

Caveats:

  • When sending the text, vim prompts you with a more screen in which you
    must press Enter repeatedly to scroll to the end. The text is actually sent
    after you're done mashing the Enter button. I haven't found a way around
    this -- I'm new to Vimscript.

This patch addresses issue preservim#44, where @gberenfield says:

> I can't seem to paste in around 30-40 lines of code into my vimux repl.
> Anything less works fine.

I write the selected text to a temporary file, read the file with tmux,
and paste the contents into the appropriate window.

Caveats:

- When sending the text, vim prompts you with a `more` screen in which you
  must press Enter repeatedly to scroll to the end. The text is actually sent
  after you're done mashing the Enter button. I haven't found a way around
  this -- I'm new to Vimscript.
@slowkow
Copy link
Author

slowkow commented May 23, 2014

After applying c1c4e3a, I use this function to send code chunks over to my ipython session in an adjacent tmux pane:

" Send selected text to an adjacent tmux pane.
function! VimuxSlime()
  " Automatically register a tmux pane.
  if !exists("g:VimuxRunnerIndex")
    call VimuxOpenRunner()
  endif
  " Suppress the `more` screen with "Press Enter".
  silent call VimuxSendText("%cpaste\n".@v."\n--\n")
endfunction
" Yank the selection into the v register and call the function.
vmap <Leader>g "vy :call VimuxSlime() <CR>

Copy link
Member

@alerque alerque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to contribute. I hope others find this useful, but it's going to need a bit of tweaking before merging for everyone.

  1. We need some way around the "mashing enter" caveat. I don't know off hand what that can be, but maybe other contributors know?

  2. The hard coded temp file path needs to detect relevant default system temp file paths and test that it's writable before going down that road. Many systems are not going to be able to blindly write to the root tmp directory, and we don't want to stop working places we currently function.

@alerque
Copy link
Member

alerque commented Feb 14, 2021

See #115 for what looks like a much more elegant fix to the same problem. I'm not sure why it got closed, possible because the author was frustrated with the inactivity, but I think it needs to be reviewed again in light of the issue and compared to this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants